package it.davial.mgwt.client.event;

import com.google.web.bindery.event.shared.Event;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.HandlerRegistration;

public class MenuEntrySelectedEvent extends Event<MenuEntrySelectedEvent.Handler> {

	public enum MenuEntry {
		PATIENT,VISIT,MAIN
	}

	public interface Handler {
		void onAnimationSelected(MenuEntrySelectedEvent event);
	}

	private static final Type<MenuEntrySelectedEvent.Handler> TYPE = new Type<MenuEntrySelectedEvent.Handler>();
	private final MenuEntry entry;

	public static void fire(EventBus eventBus, MenuEntry entry) {
		eventBus.fireEvent(new MenuEntrySelectedEvent(entry));
	}

	public static HandlerRegistration register(EventBus eventBus, Handler handler) {
		return eventBus.addHandler(TYPE, handler);
	}

	@Override
	public com.google.web.bindery.event.shared.Event.Type<Handler> getAssociatedType() {
		return TYPE;
	}

	protected MenuEntrySelectedEvent(MenuEntry entry) {
		this.entry = entry;

	}

	@Override
	protected void dispatch(Handler handler) {
		handler.onAnimationSelected(this);

	}

	public static Type<MenuEntrySelectedEvent.Handler> getType() {
		return TYPE;
	}

	public MenuEntry getEntry() {
		return entry;
	}
}
